package com.EAIPClub.LiveStreamingManager.mapper;

import com.api.POJO.LiveStreamingManager.LiveStreamingManagerInfo;
import com.api.POJO.LiveStreamingManager.LiveStreamingManagerListInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description :
 * @Author :
 * @Date : 2021/12/9
 */
@Mapper
@Repository
public interface LiveStreamingManagerMapper {

    //---------------------RTMP---------------------

    @Insert("INSERT INTO t_rtmp VALUES (null,'${info.useremail}','${info.token}','${info.start}','${info.address}')")
    Boolean addNewRTMPInfo(@Param("info") LiveStreamingManagerInfo info);
    @Select("SELECT * FROM t_rtmp WHERE token = '${token}'")
    LiveStreamingManagerInfo getRTMPLiveStreamingInfoByToken(@Param("token") String token);
    @Delete("DELETE FROM t_rtmp WHERE token = '${token}'")
    Boolean deleteRTMPLiveStreamingInfoByToken(@Param("token")String token);




    //---------------------WebRtc---------------------

    @Insert("INSERT INTO t_webrtc VALUES (null,'${info.useremail}','${info.token}','${info.start}','${info.address}')")
    Boolean addNewWebRtcInfo(@Param("info") LiveStreamingManagerInfo info);
    @Select("SELECT * FROM t_webrtc WHERE token = '${token}'")
    LiveStreamingManagerInfo getWebRtcLiveStreamingInfoByToken(@Param("token") String token);
    @Delete("DELETE FROM t_webrtc WHERE token = '${token}'")
    Boolean deleteWebRtcLiveStreamingInfoByToken(@Param("token")String token);


    //---------------------LiveList---------------------
    @Insert("INSERT INTO t_livelist VALUES (null,'${info.token}','${info.title}')")
    Boolean addNewLiveListInfo(@Param("info") LiveStreamingManagerListInfo info);
    @Select("SELECT * FROM t_livelist WHERE token = '${token}'")
    LiveStreamingManagerListInfo getLiveListInfoByToken(@Param("token") String token);
    @Select("SELECT * FROM t_livelist WHERE 1=1")
    List<LiveStreamingManagerListInfo> getAllLiveListInfo();
    @Delete("DELETE FROM t_livelist WHERE token = '${token}'")
    Boolean deleteLiveListInfoByToken(@Param("token")String token);
}
